#include "MenuBar.h"
#include "MenuItem.h"
#include "Include.h"

FunctionViewer::Config M_config;

namespace FunctionViewer {
	MenuBar::MenuBar() {
	}

	MenuBar::~MenuBar() {
	}

	void MenuBar::init(Config con, Draw idraw) {
		config = con;
		draw = idraw;
		width = config.screenwidth;
		height = 100;
		MenuItems = 0;
	}

	MenuItem* MenuBar::createMenuItem(char* name) {
		MenuItem* f_menuitem;

		//allocate memory.
		f_menuitem = (MenuItem*)(malloc(sizeof(MenuItem)));
		if (f_menuitem == NULL) {
			printf("Memory allocation failed! Could not allocate memory for menuitem!"); std::cout << std::endl;
			return NULL;
		}

		MenuItems++;

		f_menuitem->Init(this, name, 10, 10, 100, height, draw);

		return f_menuitem;
	}

	void MenuBar::drawMenu() {
		std::cout << width << " " << height << std::endl;
		glColor3i(0, 0, 0);
		glBegin(GL_QUADS);
			glVertex2i(0, 0);
			glVertex2i(0, height);
			glVertex2i(width, height);
			glVertex2i(width, 0);
		glEnd();
	}
}